
export function clearToken() {
    wx.setStorageSync('token', '');
    getApp().globalData.token = '';
}

export function setToken(token) {
    wx.setStorageSync('token', token);
    getApp().globalData.token = token;
    getApp().initUserInfo();
}
export function getToken() {
    return wx.getStorageSync('token');
}
export function setLiveId(liveId) {
    wx.setStorageSync('liveId', liveId);
}
export function getOpenId() {
    return wx.getStorageSync('openId')
}
export function getLiveId() {
    return wx.getStorageSync('liveId');
}
export function setinviteKey(invite_key) {
    wx.setStorageSync('invite_key', invite_key);
}
export function getinviteKey() {
    return wx.getStorageSync('invite_key');
}
export function clearStorage() {
    wx.removeStorageSync('liveId');
    wx.removeStorageSync('token');
    wx.removeStorageSync('openId');
    wx.removeStorageSync('invite_key');
}



export function getStorageItem(item) {
    let res = getApp().globalData[item] || wx.getStorageSync(item)
    return res ;
}
export function setStorageItem(item ,value) {
    getApp().globalData[item] = value

    wx.setStorageSync(item,value)

}
export function clearStorageItem(item) {
    getApp().globalData[item] = ''

    wx.removeStorageSync(item)
}
export function clearAllStorageItem() {

}

/** 今天是否已经显示过升级奖励弹窗了？ */
export const isTodayShowedLevelUpBonusesPopup = ()=> {
    const today = new Date().toLocaleDateString();
    const showedDate = wx.getStorageSync('levelUpBonusesPopupShowedDate');
    return today === showedDate;
}

/** 设置今天已经显示过升级奖励弹窗了 */
export const setTodayShowedLevelUpBonusesPopup = ()=> {
    const today = new Date().toLocaleDateString();
  wx.setStorageSync('levelUpBonusesPopupShowedDate', today);
}


/**今天是否已经弹出过福利官弹窗 */
export const isTodayPopAddQyFlag = () => {
    const today = new Date().toLocaleDateString();
    const showedDate = wx.getStorageSync('addQyFlagShowedDate');
    return today === showedDate;
}

/** 设置今天已经弹出过福利官弹窗 */
export const setTodayPopAddQyFlag = () => {
    const today = new Date().toLocaleDateString();
    wx.setStorageSync('addQyFlagShowedDate', today);
}